package com.spica.spicaschool.ui.splash

import android.content.Intent
import android.util.Log
import android.view.LayoutInflater
import com.spica.spicaschool.ContentActivity
import com.spica.spicaschool.R
import com.spica.spicaschool.base.BindingActivity
import com.spica.spicaschool.databinding.ActivitySplashBinding
import com.spica.spicaschool.ui.login.LoginActivity
import com.spica.spicaschool.utils.SpUtils
import com.spica.spicaschool.utils.TOKEN_SIGN
import com.zackratos.ultimatebarx.ultimatebarx.UltimateBarX

/**
 * 欢迎页
 */
class SplashActivity : BindingActivity<ActivitySplashBinding>() {

  override fun initializer() {


    UltimateBarX.with(this)
      .colorRes(R.color.white)
      .applyStatusBar()

    if (SpUtils.getSpValue(context = this, key = TOKEN_SIGN, defaultVal = "0") != "0") {
      Log.e("welcome To Use SpicaSchool", "no first")
      startActivity(Intent(this, ContentActivity::class.java))
    } else {
      Log.e("welcome To Use SpicaSchool", "first")
      startActivity(Intent(this, LoginActivity::class.java))
    }
    finish()
  }

  override fun setupViewBinding(inflater: LayoutInflater): ActivitySplashBinding =
    ActivitySplashBinding.inflate(inflater)
}
